<?php
class Merchant_Model_OrderStatusHistory
{
	private $_table;
	public function __construct(){
		$this->_table = new Merchant_Model_DbTable_OrderStatusHistory();
	}


	public function add($row){
		return $this->_table->insert($row);
	}
	public function getByValue($value,$field='orders_code',$pageSize,$page){
		$select = $this->_table->getAdapter()->select();
		$table  = $this->_table->info('name');
		$select->from($table,'*');
		$select->where("{$field} = ?",$value);
		if($pageSize>0 and $page>0)
		{
			$start =($page-1)*$pageSize;
			$select->limit($pageSize,$start);
		}
		$select->order('osh_create_date desc');
		$select = $select->__toString();

// 		var_dump($select);exit;
		return $this->_table->getAdapter()->fetchAll($select);
	}
	
	public function getByValueCount($value,$field='orders_code'){
		$select = $this->_table->getAdapter()->select();
		$table  = $this->_table->info('name');
		$select->from($table,'*');
		$select->where("{$field} = ?",$value);
		$select = $select->__toString();
	    
		// 		var_dump($select);exit;
		return count($this->_table->getAdapter()->fetchAll($select));
	}
}